//////https://www.luogu.com.cn/problem/P1048
////
////#include<iostream>
////
////using namespace std;
////
////const int N = 110, NM = 1010;
////int w[N], t[NM], dp[N][NM];
////
////int main()
////{
////	int T, M; cin >> T >> M;
////	for (int i = 1; i <= M; i++)
////		cin >> t[i] >> w[i];
////	for (int i = 1; i <= M; i++)
////	{
////		for (int j = 1; j <= T; j++)
////		{
////			if (j >= t[i]) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - t[i]] + w[i]);
////			else dp[i][j] = dp[i - 1][j];
////		}
////	}
////	cout << dp[M][T] << endl;
////	return 0;
////}
//
//#include<iostream>
//
//using namespace std;
//
//const int N = 110, NM = 1010;
//int w[N], t[NM], dp[NM];
//
//int main()
//{
//	int T, M; cin >> T >> M;
//	for (int i = 1; i <= M; i++)
//		cin >> t[i] >> w[i];
//	for (int i = 1; i <= M; i++)
//		for (int j = T; j >= t[i]; j--)
//			dp[j] = max(dp[j], dp[j - t[i]] + w[i]);
//	cout << dp[T] << endl;
//	return 0;
//}